﻿package dungeonCode
{
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.net.URLLoader;
	import flash.net.URLRequest;
	
	/**
	 * @author Josh Davis
	 */
	
	public class Document extends Sprite 
	{
		public var game:Game;
		private var levelXML:XML;
		
		public function Document() 
		{
			var xmlRequest:URLRequest = new URLRequest("levels.xml");
			var xmlLoader:URLLoader = new URLLoader(xmlRequest);
			
			xmlLoader.addEventListener(Event.COMPLETE, onXMLLoaded);
		}
		
		public function onXMLLoaded(e:Event):void
		{
			levelXML = new XML(e.target.data);
			game = new Game(levelXML);
			addChild(game);
			game.begin();
		}
	}
}